package DataStructure;

/**
 * 递归
 *
 * @time: 2021/4/22/022 20:28
 * @author: Zhurunhe
 */
public class RecursionTest {
    public static void main(String[] args) {
//        print(10);
        System.out.println(cal(5));

    }

    public static void print(int n) {
        if (n > 2) {//递归终止条件
            print(n - 1);
        }
        System.out.println("n=" + n);
    }

    public static int cal(int n) {
        if (n == 1||n==0) {
            return 1;//递归终止条件
        }
        return cal(n - 1) * n;
    }
}
